--- import type { CollectionEntry } from "astro:content"; import { getCollection, render } from "astro:content"; import BaseLayout from "../layouts/BaseLayout.astro"; import Separator from "../components/Separator.astro"; import AlbumGrid from "../components/AlbumGrid.astro"; export const getStaticPaths = async () => { // Fetch all artists from the 'artists' collection const artists = await getCollection("artists"); // Map over the artists to generate paths for each artist's page const paths = artists.map((artist) => { return { params: { artist_id: artist.id }, // URL parameter for the artist's ID props: { artists, artist }, // Pass the full artist and all artists as props }; }); // Return the generated paths to Astro for static page generation return paths; }; type Props = { artists: CollectionEntry<"artists">[]; // Array of all artists in the collection artist: CollectionEntry<"artists">; // Current artist being rendered }; const { artists, artist } = Astro.props; // Extract the artists list and current artist from the props // Extract the ID of the current artist const artist_id = artist.id; // Find the index of the current artist in the artists array const currentArtistIndex = artists.findIndex((a) => a.id === artist_id); // Calculate the index of the "next" artist in the array (wrap around if at the last artist) const nextArtistIndex = (currentArtistIndex + 1) % artists.length; // Get the "next" artist based on the calculated index const nextArtist = artists[nextArtistIndex]; // Fetch all albums that belong to the current artist const albums = await getCollection( "albums", ({ data }) => data.artist.id === artist_id, ); // Render the content of the current artist (e.g., markdown or MDX) const { Content } = await render(artist); ---

{artist.data.stage_name} ({artist.data.name})

View all / Next artist
{artist.data.image.alt}

Biography

Genre
{artist.data.genre}
{ albums.length > 0 && (

Releases

) }